//
//  GestureImageView.m
//  UI_07homeworkNavigationAndGesture
//
//  Created by dllo on 16/6/14.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "GestureImageView.h"
#import "SecondViewController.h"
#import "ViewController.h"

@interface GestureImageView ()


@end




@implementation GestureImageView

-(instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        self.userInteractionEnabled = YES;
//        self.frame = frame;
        
        [self addTap];
    }
    return self;
    
}
-(instancetype)initWithImageName:(NSString *)imageName withFrame:(CGRect)frame{
    
    self = [super initWithImage:[UIImage imageNamed:imageName]];
    if (self) {
        self.userInteractionEnabled = YES;
        self.frame = frame;
        
        [self addTap];
    }
    return self;
}

-(void)addTap{
    
    UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(action:)];
    [self addGestureRecognizer:tapGesture];
    [tapGesture release];

    
}

-(void)action:(UITapGestureRecognizer *)tap{
    
    
    [self.delegate tapToJumpwithTag:self.tag - 1000];
    
}




@end
